package function

import (
	"math/rand"
	"time"
)

/*  =============== 默认值 ==================  */

type DefaultNumberFunction struct {
	size  int
	value int
	data  []interface{}
}

// DefaultNumber 默认
func DefaultNumber(size, value int) *DefaultNumberFunction {
	return &DefaultNumberFunction{
		size:  size,
		value: value,
		data:  make([]interface{}, 0, size),
	}
}

func (d *DefaultNumberFunction) Build() []interface{} {
	rand.Seed(time.Now().Unix())
	for i := 0; i < d.size; i++ {
		d.data = append(d.data, d.value)
	}
	return d.data
}

/*  =============== 范围值 ==================  */

type RangeFunction struct {
	size int
	min  int
	max  int
	data []interface{} // 存放数据
}

// RangeNumber 范围
func RangeNumber(size, min, max int) *RangeFunction {
	return &RangeFunction{
		size: size,
		min:  min,
		max:  max,
		data: make([]interface{}, 0, size),
	}
}

func (r *RangeFunction) Build() []interface{} {
	rand.Seed(time.Now().Unix())
	for i := 0; i < r.size; i++ {
		r.data = append(r.data, rand.Intn(r.max-r.min)+r.min)
	}
	return r.data
}
